import 'package:library_base/entities/generated/json/base/json_field.dart';
import 'package:library_base/entities/generated/json/goods_child_entity.g.dart';
import 'dart:convert';

import 'package:library_base/entities/goods_child_info_entity.dart';

@JsonSerializable()
class GoodsChildEntity {
  List<GoodsChildInfoEntity> goodsDetails = [];

  String? id;
  String? barRules;
  late String goodsCode;
  late String goodsName;
  String? skuName;
  double? standardWeight;
  String? pricingMode;
  String? vulgo;
  String? shipperName;
  late String unit;
  String? materialFlag;
  String? createTime;
  String? updateTime;
  late bool singleEntry;

  double? totalCount;
  double? price;
  double? totalWeight;
  double? get purchaseAmount {
    if (totalWeight == null || price == null) {
      return null;
    } else {
      return totalWeight! * price!;
    }
  }

  double? serviceCost;

  bool isSelect = false;

  bool isExpand = false;

  GoodsChildEntity();

  factory GoodsChildEntity.fromJson(Map<String, dynamic> json) => $GoodsChildEntityFromJson(json);

  Map<String, dynamic> toJson() => $GoodsChildEntityToJson(this);

  @override
  String toString() => json.encode(this);

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is GoodsChildEntity && runtimeType == other.runtimeType && goodsCode == other.goodsCode;

  @override
  int get hashCode => goodsCode.hashCode;
}
